package com.wing.ext.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.wing.common.CommonSpringJDBC;
import com.wing.common.util.PageBean;
import com.wing.ext.domain.Site_user;

@Repository
public class Site_userDao extends CommonSpringJDBC<Site_user, String> {

	public PageBean findPageList(int currentPage, int pageSize,String siteId) {
		String where= " site_id='"+siteId+"' ";
		String sql1=" SELECT * FROM ext_site_user where "+where+" ORDER BY id ASC " +
			" LIMIT "+(currentPage-1) * pageSize+","+pageSize;
		String sql2 = "select count(id) from  ext_site_user  where"+where;
		String[] sqlArray = {sql1,sql2 };
		return super.findPageList(sqlArray, currentPage, pageSize);
	}


	public List findUsersByLoginName(String lgname) {
		String sql = "select * from ext_site_user t where login_name = ?";
		return super.getSimpleJdbcTemplate().queryForList(sql,lgname);
	}


	public List<Map<String, Object>> findSiteUser(String site_id,
			String login_name, String password) {
		String sql = "select * from ext_site_user t where site_id=? and login_name = ? and password=? ";
		Object [] objs = {site_id,login_name,password};
		return super.getSimpleJdbcTemplate().queryForList(sql,objs);
	}
}
